﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace ElementumForever.Utility
{
    public class FpsMonitor
    {
        public float Value { get { return _fps; } }

        int _total_frames = 0;
        float _elapsed_time = 0.0f;
        int _fps = 0;

        public FpsMonitor()
        {
          
        }

        public void Update(GameTime gameTime)
        {
           // Update
            _elapsed_time += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
 
            // 1 Second has passed
            if (_elapsed_time >= 1000.0f)
            {
                _fps = _total_frames;
                _total_frames = 0;
                _elapsed_time = 0;
            }
            _total_frames++;
            
        }

        //public void Draw(SpriteBatch SpriteBatch, SpriteFont Font, Vector2 Location, Color Color)
        //{
        //    this.Frames++;
        //    SpriteBatch.DrawString(Font, "FPS: " + this.Value.ToString(), Location, Color);
        //}
    }
}
